/**
 * 
 */
package de.gee.erep.shared.entities.citizen.details;

import de.gee.erep.shared.entities.citizen.CitizenDetail;
import de.gee.erep.shared.entities.citizen.CitizenDetailId;

/**
 * @author Matthew Gee created: 07.05.2011
 */
public class Card implements CitizenDetail {
	public static String[] fieldnames = { "sex", "wellness", "level",
			"experience-points", "work-skill-points", "employer" };
	/***/
	private static final long serialVersionUID = 1L;
	CitizenDetailId id;
	String sex;
	double wellness;
	int level;
	int experiencePoints;
	int workSkillPoints;
	int employerId;

	public Card() {
	}

	public Card(CitizenDetailId id, String sex, int wellness, int level,
			int experiencePoints, int workSkillPoints, int employerId) {
		this.id = id;
		this.sex = sex;
		this.wellness = wellness;
		this.level = level;
		this.experiencePoints = experiencePoints;
		this.workSkillPoints = workSkillPoints;
		this.employerId = employerId;
	}

	/**
	 * @param citizenDetailId
	 */
	public Card(CitizenDetailId citizenDetailId) {
		this.id = citizenDetailId;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see de.gee.erep.shared.entities.citizen.CitizenDetail#getId()
	 */
	@Override
	public CitizenDetailId getId() {
		return id;
	}

	/**
	 * @param element
	 * @param data
	 */
	public void set(String element, String data) {
		try {
			if (element.equals("sex")) {
				sex = data;
			} else if (element.equals("wellness")) {
				wellness = Double.valueOf(data);
			} else if (element.equals("level")) {
				level = Integer.valueOf(data);
			} else if (element.equals("experience-points")) {
				experiencePoints = Integer.valueOf(data);
			} else if (element.equals("work-skill-points")) {
				workSkillPoints = Integer.valueOf(data);
			} else if (element.equals("employerId")) {
				employerId = Integer.valueOf(data);
			}
		} catch (NumberFormatException e) {
			System.err.println("idNotSet");
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Card [id=" + id + ", sex=" + sex + ", wellness=" + wellness
				+ ", level=" + level + ", experiencePoints=" + experiencePoints
				+ ", workSkillPoints=" + workSkillPoints + ", employerId="
				+ employerId + "]";
	}

}
